package com.sun.mybatisplus.controller;

import cn.hutool.core.date.DateTime;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.sun.mybatisplus.bean.User;
import com.sun.mybatisplus.bean.dto.FormItemUpdateDTO;
import com.sun.mybatisplus.bean.dto.RelevanceDataDTO;
import com.sun.mybatisplus.bean.entity.TblFormModel;
import com.sun.mybatisplus.bean.entity.TblFormModelConfig;
import com.sun.mybatisplus.bean.enums.ModelConfigTypeEnum;
import com.sun.mybatisplus.bean.vo.ConfiguredPaymentWay;
import com.sun.mybatisplus.bean.vo.FormItemInfoVO;
import com.sun.mybatisplus.bean.vo.PaymentWayVO;
import com.sun.mybatisplus.bean.vo.RelevanceDataVO;
import com.sun.mybatisplus.mapper.FormModelConfigMapper;
import com.sun.mybatisplus.mapper.FormModelMapper;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

@RestController
public class FormModelController {
    @Resource
    private FormModelMapper formModelMapper;

    @Resource
    private FormModelConfigMapper formModelConfigMapper;

    @RequestMapping("/insert")
    public String insert(@RequestBody FormItemUpdateDTO dto) {
        TblFormModel formModel = new TblFormModel();
        BeanUtils.copyProperties(dto, formModel);
        //处理单据配置
        RelevanceDataDTO relevanceDataDTO = dto.getRelevanceDataDTO();
        if (relevanceDataDTO != null) {
            formModelConfigMapper.delete(new QueryWrapper<TblFormModelConfig>().eq("FORM_MODEL_ID",dto.getId()));
            TblFormModelConfig config = setModelConfig(dto);
            List<JSONObject> assignBudgetPlan = relevanceDataDTO.getAssignBudgetPlan();
            if (CollectionUtils.isNotEmpty(assignBudgetPlan)) {
                assignBudgetPlan.forEach(plan -> {
                    config.setId(System.currentTimeMillis());
                    config.setChooseId(Long.valueOf(String.valueOf(plan.get("id"))));
                    config.setChooseName(String.valueOf(plan.get("planName")));
                    saveModelConfig(config, ModelConfigTypeEnum.assignBudgetPlan);
                });
            }
            List<JSONObject> assignBudget = relevanceDataDTO.getAssignBudget();
            if (CollectionUtils.isNotEmpty(assignBudget)) {
                assignBudget.forEach(budget -> {
                    config.setId(System.currentTimeMillis());
                    config.setChooseId(Long.valueOf(String.valueOf(budget.get("id"))));
                    config.setChooseName(String.valueOf(budget.get("project")));
                    saveModelConfig(config, ModelConfigTypeEnum.assignBudget);
                });
            }
            Set<JSONObject> personAssignRange = relevanceDataDTO.getPersonAssignRange();
            personAssignRange.forEach(person -> {
                config.setId(System.currentTimeMillis());
                config.setChooseId(Long.valueOf(String.valueOf(person.get("id"))));
                config.setChooseName(String.valueOf(person.get("name")));
                saveModelConfig(config, ModelConfigTypeEnum.personRange);
            });
            RelevanceDataDTO setRelevanceDataDTO = new RelevanceDataDTO();
            relevanceDataDTO.setAssignBudgetPlan(setRelevanceDataDTO.getAssignBudgetPlan());
            relevanceDataDTO.setAssignBudget(setRelevanceDataDTO.getAssignBudget());
            relevanceDataDTO.setPersonAssignRange(setRelevanceDataDTO.getPersonAssignRange());
            formModel.setRelevanceData(JSONUtil.toJsonStr(relevanceDataDTO));
        }
        formModelMapper.insert(formModel);

        return "success";
    }
    @Test
    public void show(){
        RelevanceDataDTO dto = new RelevanceDataDTO();
        dto.setMemo("测试一下");
        cn.hutool.json.JSON jsonStr = JSONUtil.parse(dto);
        if (dto.getEnableAddMoney() == null){
            System.out.println("enableAddMoney是空的");
        }
        dto.setEnableAddMoney(dto.getEnableAddMoney() == null ? 1 : dto.getEnableAddMoney());
        System.out.println(dto.getEnableAddMoney());
        RelevanceDataVO relevanceDataVO = new RelevanceDataVO();
        setDefaultValue(relevanceDataVO);
        System.out.println(relevanceDataVO);
        PaymentWayVO paymentWayVO = new PaymentWayVO();
        List<ConfiguredPaymentWay> configuredPaymentWays = Arrays.asList(new ConfiguredPaymentWay(1L, "123", "23"), new ConfiguredPaymentWay(1L, "123", "23"));
        paymentWayVO.setConfiguredPaymentWay(configuredPaymentWays);
        paymentWayVO.setDefaultPaymentWay(7897L);
        paymentWayVO.setType((byte) 1);
        jsonStr.putByPath("paymentWayVO",paymentWayVO);
        System.out.println("转换后的json=====>" + jsonStr);



    }
    private void setDefaultValue(RelevanceDataVO relevanceDataVO) {
        relevanceDataVO.setEnableBudget(relevanceDataVO.getEnableBudget() == null ? 1 : relevanceDataVO.getEnableBudget());
        relevanceDataVO.setEnableAddMoney(relevanceDataVO.getEnableAddMoney() == null ? 0 : relevanceDataVO.getEnableAddMoney());
        relevanceDataVO.setEnableMoreApply(relevanceDataVO.getEnableMoreApply() == null ? 0 : relevanceDataVO.getEnableMoreApply());

    }
    public TblFormModelConfig setModelConfig(FormItemUpdateDTO dto) {
        TblFormModelConfig config = new TblFormModelConfig();
        config.setFormModelId(dto.getId());
        config.setLastModifyUserId(dto.getId());
        config.setLastModifyUserId(dto.getId());
        config.setLastModifyTime(LocalDateTime.now());
        config.setCreateTime(LocalDateTime.now());
        return config;
    }

    public void saveModelConfig(TblFormModelConfig config, ModelConfigTypeEnum typeEnum) {
        config.setType(typeEnum.getCode());
        formModelConfigMapper.insert(config);
    }

    @RequestMapping("select")
    public FormItemInfoVO sel(Long id){
        FormItemInfoVO formItemInfoVO = new FormItemInfoVO();
        TblFormModel formModel = formModelMapper.selectById(id);
        BeanUtils.copyProperties(formModel, formItemInfoVO);
        formItemInfoVO.setTypeName(formModel.getType());
        formItemInfoVO.setFlowRuleCode(formModel.getFlowRuleCode());
        String paymentWay = formModel.getPaymentWay();
        if (StringUtils.isNotBlank(paymentWay) && JSONUtil.isJson(paymentWay)){
            PaymentWayVO paymentWayVO = JSONUtil.toBean(paymentWay, PaymentWayVO.class);
            formItemInfoVO.setPaymentWayVO(paymentWayVO);
        }
        String relevanceData = formModel.getRelevanceData();
        if (StringUtils.isNotBlank(relevanceData) && JSONUtil.isJson(relevanceData)){
            formItemInfoVO.setRelevanceDataVO(getRelevanceDataVO(formModel));
        }




        return formItemInfoVO;
    }
    private RelevanceDataVO getRelevanceDataVO(TblFormModel formModel) {
        RelevanceDataVO relevanceDataVO = JSONUtil.toBean(formModel.getRelevanceData(), RelevanceDataVO.class);
        List<TblFormModelConfig> configs = formModelConfigMapper.selectList(new QueryWrapper<TblFormModelConfig>().eq("FORM_MODEL_ID", formModel.getId()));
        relevanceDataVO.setAssignBudgetPlan(configs.stream().filter(config -> config.getType().equals(ModelConfigTypeEnum.assignBudgetPlan.getCode())).map(config -> {
            JSONObject jsonObject = new JSONObject();
            jsonObject.set("id", config.getChooseId());
            jsonObject.set("planName", config.getChooseName());
            return jsonObject;
        }).collect(Collectors.toList()));
        relevanceDataVO.setAssignBudget(configs.stream().filter(config -> config.getType().equals(ModelConfigTypeEnum.assignBudget.getCode())).map(config -> {
            JSONObject jsonObject = new JSONObject();
            jsonObject.set("id", config.getChooseId());
            jsonObject.set("project", config.getChooseName());
            return jsonObject;
        }).collect(Collectors.toList()));
        relevanceDataVO.setPersonAssignRange(configs.stream().filter(config -> config.getType().equals(ModelConfigTypeEnum.personRange.getCode())).map(config -> {
            JSONObject jsonObject = new JSONObject();
            jsonObject.set("id", config.getChooseId());
            jsonObject.set("name", config.getChooseName());
            return jsonObject;
        }).collect(Collectors.toSet()));
        return relevanceDataVO;
    }

    @RequestMapping("/all")
    public User all(@RequestBody User user) {

        System.out.println(user);
        return user;
    }

    @RequestMapping("/alls")
    public RelevanceDataDTO alls(Long id) {
        System.out.println(id);
        TblFormModel tblFormModel = formModelMapper.selectById(id);
        RelevanceDataDTO relevanceDataDTO = JSONUtil.toBean(tblFormModel.getRelevanceData(), RelevanceDataDTO.class);

        return relevanceDataDTO;
    }

    public static void main(String[] args) {
        String str = "[{\"planName\":\"执行测试\",\"budgetCount\":1,\"id\":\"e9846583-a031-4acf-b765-6271c4650790\",\"elementList\":[{\"elementName\":\"指标文号\",\"id\":\"f0cb223f-3078-462f-a106-c1becc90adc0\"},{\"elementName\":\"资金性质\",\"id\":\"7b9ecbac-75aa-4a20-8ca5-4ebfd779f144\"},{\"elementName\":\"部门经济分类\",\"id\":\"16a7e9a3-3774-45a1-b636-e028da958231\"},{\"elementName\":\"总金额\",\"id\":\"35eb81f1-2a94-4de6-87fa-d18bec04e472\"},{\"elementName\":\"功能分类\",\"id\":\"e843f74c-bd4a-44bc-bfa5-4d682bfcd103\"},{\"elementName\":\"政府经济分类\",\"id\":\"a61097c8-f52b-433f-9006-e94856d6cd31\"},{\"elementName\":\"附件\",\"id\":\"1526481859745710081\"},{\"elementName\":\"下达日期\",\"id\":\"1526482183785054209\"},{\"elementName\":\"支出部门\",\"id\":\"7470a9f2-7a5f-4abd-95bb-3f2a300b59b0\"},{\"elementName\":\"年初已执行\",\"id\":\"1527845173990633474\"},{\"elementName\":\"所属单位\",\"id\":\"ec94d218-1761-4261-aa71-47faba64694d\"},{\"elementName\":\"执行经济科目\",\"id\":\"1530445904933367809\"}]}]";
        List<JSONObject> jsonObjects = JSON.parseArray(str, JSONObject.class);
        System.out.println(jsonObjects);
        String str1 = "{\"personRangeType\":2,\"enableMoreApply\":1,\"maxMoney\":1111,\"selMultiBudget\":1,\"enableAddMoney\":1,\"statementType\":1,\"enableBudget\":1}";
        RelevanceDataDTO relevanceDataDTO = JSONUtil.toBean(str1, RelevanceDataDTO.class);
        System.out.println(relevanceDataDTO);
        String str2 = "{\"personRangeType\":2,\"applyFormId\":1413400548010496000,\"costTypeType\":2,\"selMultiBudget\":1,\"costAssignRange\":[1525377612430471169],\"personAssignRange\":[{\"id\":\"1531318880796938241\",\"username\":\"a0001\"},{\"id\":\"1531174599889260545\",\"username\":\"张亨超2\"}],\"relevanceBefore\":1,\"budgetRangeType\":2,\"enableBudget\":1}";
        System.out.println(str2.length());
        System.out.println(String.valueOf(System.currentTimeMillis()).length());

    }

    @Test
    public void test2(){
        String sql = "select * from user_tab_columns WHERE table_name = '?'";

        String str = "TBL_DEPARTMENT,TBL_USER_FAMILY_INFORMATION,tbl_process_instance_user,tbl_process_instance," +
                "Tbl_User_Permission,tbl_user_info,TBL_USER_ACCOUNT,TBL_USER_BANK_ACCOUNT,TBL_POSITION,Tbl_File," +
                "tbl_contract_history,TBL_PERMISSION,TBL_MENU,tbl_ledger,tbl_reimburse_fee,Tbl_System_User,tbl_project," +
                "TBL_MEDICAL_INFO,TBL_SETTLEMENT,TBL_PROCESS_PROGRESS,tbl_contract,tbl_payment_plan,TBL_TRAVEL_STANDARD," +
                "TBL_MESSAGE,Tbl_Instance_Assist,TBL_DATA_BEFORE_TRAVEL_UNIT";
        String[] split = str.toUpperCase().split(",");
        for (String s : split) {
            System.out.println(sql.replace("?",s));
        }

    }
    @Test
    public void test3(){
        /*ALTER TABLE TBL_DEPARTMENT MODIFY ID NUMBER(100);
        alter table TBL_DEPARTMENT  rename column   ID  to ID_NEW;
        alter table TBL_DEPARTMENT add ID varchar2(100);
        update TBL_DEPARTMENT set ID=ID_NEW;
        alter table TBL_DEPARTMENT drop column ID_NEW;
        alter table TBL_DEPARTMENT add constraint CONS134218784 primary key (ID);

        ALTER TABLE TBL_DEPARTMENT MODIFY ORGANIZATION_ID NUMBER(100);
        alter table TBL_DEPARTMENT  rename column   ORGANIZATION_ID  to ORGANIZATION_ID_NEW;
        alter table TBL_DEPARTMENT add ORGANIZATION_ID varchar2(100);
        update TBL_DEPARTMENT set ORGANIZATION_ID=ORGANIZATION_ID_NEW;
        alter table TBL_DEPARTMENT drop column ORGANIZATION_ID_NEW;


        ALTER TABLE TBL_DEPARTMENT MODIFY PARENT_ID NUMBER(100);





        ALTER TABLE TBL_DEPARTMENT MODIFY MAIN_LEADER NUMBER(100);
        ALTER TABLE TBL_DEPARTMENT MODIFY BRANCH_LEADER NUMBER(100);


        ALTER TABLE TBL_USER_FAMILY_INFORMATION MODIFY ID NUMBER(100);
        ALTER TABLE TBL_USER_FAMILY_INFORMATION MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_PROCESS_INSTANCE_USER MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_PROCESS_INSTANCE MODIFY APPROVER_ID NUMBER(100);
        ALTER TABLE TBL_PROCESS_INSTANCE MODIFY HANDLER_ID NUMBER(100);
        ALTER TABLE TBL_PROCESS_INSTANCE MODIFY DEPARTMENT_ID NUMBER(100);
        ALTER TABLE TBL_PROCESS_INSTANCE MODIFY APPLICANT_ID NUMBER(100);


        ALTER TABLE TBL_USER_PERMISSION MODIFY ID NUMBER(100);
        ALTER TABLE TBL_USER_PERMISSION MODIFY PERMISSION_ID NUMBER(100);
        ALTER TABLE TBL_USER_PERMISSION MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_USER_INFO MODIFY ID NUMBER(100);
        ALTER TABLE TBL_USER_INFO MODIFY DEPT_ID NUMBER(100);
        ALTER TABLE TBL_USER_INFO MODIFY ORG_ID NUMBER(100);
        ALTER TABLE TBL_USER_INFO MODIFY REIMBURSE_USER_ID NUMBER(100);


        ALTER TABLE TBL_USER_ACCOUNT MODIFY ID NUMBER(100);
        ALTER TABLE TBL_USER_ACCOUNT MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_USER_BANK_ACCOUNT MODIFY ID NUMBER(100);
        ALTER TABLE TBL_USER_BANK_ACCOUNT MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_USER_BANK_ACCOUNT MODIFY USER_ID NUMBER(100);
        ALTER TABLE TBL_USER_BANK_ACCOUNT MODIFY ID NUMBER(100);


        ALTER TABLE TBL_POSITION MODIFY ID NUMBER(100);


        ALTER TABLE TBL_FILE MODIFY UPLOAD_USER NUMBER(100);


        ALTER TABLE TBL_FILE MODIFY UPLOAD_USER NUMBER(100);


        ALTER TABLE TBL_CONTRACT_HISTORY MODIFY CHANGE_USER_ID NUMBER(100);


        ALTER TABLE TBL_PERMISSION MODIFY ID NUMBER(100);
        ALTER TABLE TBL_PERMISSION MODIFY POSITION_ID NUMBER(100);
        ALTER TABLE TBL_PERMISSION MODIFY DEPT_ID NUMBER(100);


        ALTER TABLE TBL_MENU MODIFY ID NUMBER(100);
        ALTER TABLE TBL_MENU MODIFY PARENT_ID NUMBER(100);
        ALTER TABLE TBL_MENU MODIFY MODEL_ID NUMBER(100);


        ALTER TABLE TBL_LEDGER MODIFY USER_ID NUMBER(100);
        ALTER TABLE TBL_LEDGER MODIFY CONSUMER_ID NUMBER(100);


        ALTER TABLE TBL_REIMBURSE_FEE MODIFY REIMBURSER NUMBER(100);


        ALTER TABLE TBL_SYSTEM_USER MODIFY ID NUMBER(100);


        ALTER TABLE TBL_PROJECT MODIFY MANAGER_ID NUMBER(100);


        ALTER TABLE TBL_MEDICAL_INFO MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_SETTLEMENT MODIFY LOANMAN_ID NUMBER(100);


        ALTER TABLE TBL_PROCESS_PROGRESS MODIFY OPERATOR_ID NUMBER(100);


        ALTER TABLE TBL_CONTRACT MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_PAYMENT_PLAN MODIFY PAYER_ID NUMBER(100);


        ALTER TABLE TBL_MESSAGE MODIFY SENDER_ID NUMBER(100);
        ALTER TABLE TBL_MESSAGE MODIFY RECE_ID NUMBER(100);


        ALTER TABLE TBL_INSTANCE_ASSIST MODIFY DEPT_ID NUMBER(100);
        ALTER TABLE TBL_INSTANCE_ASSIST MODIFY USER_ID NUMBER(100);


        ALTER TABLE TBL_DATA_BEFORE_TRAVEL_UNIT MODIFY ORG_ID NUMBER(100);
        ALTER TABLE TBL_DATA_BEFORE_TRAVEL_UNIT MODIFY DEPT_ID NUMBER(100);
        ALTER TABLE TBL_DATA_BEFORE_TRAVEL_UNIT MODIFY USER_ID NUMBER(100);*/
    }

    @Test
    public void test4(){
        String tbl = "TBL_DATA_BEFORE_TRAVEL_UNIT";
        List<String> list = Arrays.asList("DEPT_ID","USER_ID","ORG_ID");
        String sql1 = "alter table tbl  rename column   old  to new;".replace("tbl", tbl);
        String sql2 = "alter table tbl  add old varchar2(100);".replace("tbl", tbl);
        String sql3 = "update tbl set old = new;".replace("tbl", tbl);
        String sql4 = "alter table tbl drop column new;".replace("tbl", tbl);

        list.forEach(c -> {
            String d = c + "_new";
            String nsql1 = sql1.replace("old", c).replace("new", d);
            String nsql2 = sql2.replace("old", c);
            String nsql3 = sql3.replace("old", c).replace("new", d);
            String nsql4 = sql4.replace("new", d);
            System.out.println(nsql1);
            System.out.println(nsql2);
            System.out.println(nsql3);
            System.out.println(nsql4);
            System.out.println("==============================");
        });
    }

    @Test
    public void test5(){
        String tbl = "TBL_BUDGET,TBL_BUDGET_HIST,TBL_CITY_FEE,TBL_COMMODITY_CODE,TBL_CONFIG,TBL_CONTRACT," +
                "TBL_CONTRACT_HISTORY,TBL_DATA_AFTER,TBL_DATA_AFTER_LABOUR,TBL_DATA_AFTER_MEDICAL,TBL_DATA_AFTER_MEETING_AH," +
                "TBL_DATA_AFTER_OFFICE,TBL_DATA_AFTER_PRINTING,TBL_DATA_AFTER_RECN_AH,TBL_DATA_AFTER_REPAIR," +
                "TBL_DATA_AFTER_TRAIN_AH,TBL_DATA_BEFORE_JDACTIVITY,TBL_DATA_BEFORE_RECN_AH,TBL_DATA_BEFORE_RECN_AH_GUEST," +
                "TBL_DATA_BEFORE_RECN_AH_UNIT,TBL_DATA_FEE_SUMMARY,TBL_DATA_INVOICE_DETAIL,TBL_DATA_LEND_MONEY,TBL_DATA_LM_PROJECT," +
                "TBL_DATA_PERSONNEL,TBL_DATA_PERSON_INJURY_CLAIMS,TBL_DATA_REPAYMENT,TBL_DATA_SZSQ_BEFORE,TBL_DATA_WRITE_OFF," +
                "TBL_DEPARTMENT,TBL_DICTIONARY,TBL_DICTIONARY_TYPE,TBL_DYNAMIC_TABLE,TBL_FEE_COST,TBL_FLOW_RULE," +
                "TBL_FORM_MODEL,TBL_ACCOUNT,TBL_GENERAL_STANDARD,TBL_INSTANCE_ASSIST,TBL_INSTANCE_REPORT,TBL_INVOICE," +
                "TBL_INVOICE_ELEMENT,TBL_INVOICE_VERIFY_HISTORY,TBL_LEDGER,TBL_LR_LEND_MONEY_INFO,TBL_LR_REPAYMENT_LOG,TBL_LR_WRITEOFF," +
                "TBL_MEETING_FEE,TBL_MENU,TBL_OTHER_FEE_STANDARD,TBL_POSITION,TBL_PROCESS_DEFINITION,TBL_PROCESS_INSTANCE," +
                "TBL_PROCESS_INSTANCE_EXT,TBL_PROCESS_INSTANCE_USER,TBL_PROCESS_PROGRESS,TBL_PROJECT,TBL_RANK,TBL_RULE_CHECK_RESULT," +
                "TBL_RULE_CONFIG,TBL_RULE_FORM_CONFIG,TBL_RULE_GROUP_CONFIG,TBL_SETTLEMENT,TBL_STATION,TBL_SUBSIDY_STANDARD," +
                "TBL_SYNC_INTERFACE,TBL_TEACHER_COURSE_STANDARD,TBL_TRAFFIC_STANDARD,TBL_TRAVEL_STANDARD,TBL_USER_BANK_ACCOUNT," +
                "TBL_USER_FAMILY_INFORMATION,TBL_USER_INFO,TBL_VEHICLE_STANDARD";
        //有CREATOR_ID字段
        String tbl1 = "TBL_DATA_AFTER_MEETING,TBL_DATA_AFTER_OTHER,TBL_DATA_AFTER_RECEPTION,TBL_DATA_AFTER_TRAIN," +
                "TBL_DATA_AFTER_TRAVEL,TBL_DATA_AFTER_TRAVEL_BUDGET,TBL_DATA_AFTER_TRAVEL_TRIP,TBL_DATA_BEFORE_GENERAL," +
                "TBL_DATA_BEFORE_MEETING,TBL_DATA_BEFORE_RECEPTION,TBL_DATA_BEFORE_RECEPTION_UNIT,TBL_DATA_BEFORE_RECN_GUEST," +
                "TBL_DATA_BEFORE_TRAIN,TBL_DATA_BEFORE_TRAVEL,TBL_DATA_BEFORE_TRAVEL_PLAN,TBL_DATA_BEFORE_TRAVEL_UNIT," +
                "TBL_MEETING";

        String sql1 = "alter table tbl  rename column   LAST_MODIFY_USER_ID  to LAST_MODIFY_USER_ID_NEW;";
        String sql2 = "alter table tbl  add LAST_MODIFY_USER_ID varchar2(100);";
        String sql3 = "update tbl set LAST_MODIFY_USER_ID = LAST_MODIFY_USER_ID_NEW;";
        String sql4 = "alter table tbl drop column LAST_MODIFY_USER_ID_NEW;";

        String sql5 = "alter table tbl  rename column   CREATOR_ID  to CREATOR_ID_NEW;";
        String sql6 = "alter table tbl  add CREATOR_ID varchar2(100);";
        String sql7 = "update tbl set CREATOR_ID = CREATOR_ID_NEW;";
        String sql8 = "alter table tbl drop column CREATOR_ID_NEW;";
        List<String> list = Arrays.asList(tbl.split(","));
        list.forEach(c -> {
            String nsql1 = sql1.replace("tbl", c);
            String nsql2 = sql2.replace("tbl", c);
            String nsql3 = sql3.replace("tbl", c);
            String nsql4 = sql4.replace("tbl", c);
            String nsql5 = sql5.replace("tbl", c);
            String nsql6 = sql6.replace("tbl", c);
            String nsql7 = sql7.replace("tbl", c);
            String nsql8 = sql8.replace("tbl", c);
            System.out.println(nsql1);
            System.out.println(nsql2);
            System.out.println(nsql3);
            System.out.println(nsql4);
            System.out.println(nsql5);
            System.out.println(nsql6);
            System.out.println(nsql7);
            System.out.println(nsql8);
            System.out.println("======================");
        });
        System.out.println("》》》》》》》》》》》》》》》》》》》》》");
        List<String> list1 = Arrays.asList(tbl1.split(","));
        list1.forEach(c->{
            String nsql1 = sql5.replace("tbl", c);
            String nsql2 = sql6.replace("tbl", c);
            String nsql3 = sql7.replace("tbl", c);
            String nsql4 = sql8.replace("tbl", c);
            System.out.println(nsql1);
            System.out.println(nsql2);
            System.out.println(nsql3);
            System.out.println(nsql4);
            System.out.println("============================");
        });
    }

    @Test
    public void test6(){
        Date date = new Date();
        System.out.println(date);
        DateTime of = DateTime.of(date);
        System.out.println(of);
    }

}
